<nz-page-header nzGhost="false">
    <nz-page-header-title>应用列表</nz-page-header-title>
    <nz-page-header-subtitle>Materal-ConDep</nz-page-header-subtitle>
    <nz-page-header-extra>
        <nz-button-group>
            <button nz-button nzType="primary" (click)="clearCache()">清理缓存</button>
            <button nz-button (click)="openDrawer(null)">新增应用</button>
            <button nz-button nzType="primary" (click)="StartAllApp()">全部启动</button>
            <button nz-button nzType="danger" (click)="StopAllApp()">全部停止</button>
        </nz-button-group>
    </nz-page-header-extra>
    <nz-page-header-content>
        <nz-descriptions nzColumn="3">
            <nz-descriptions-item nzTitle="总数" nzSpan="1">{{generalMessage.count}}</nz-descriptions-item>
            <nz-descriptions-item nzTitle="运行" nzSpan="1">{{generalMessage.run}}</nz-descriptions-item>
            <nz-descriptions-item nzTitle="停止" nzSpan="1">{{generalMessage.stop}}</nz-descriptions-item>
        </nz-descriptions>
        <form nz-form [formGroup]="searchModel" autocomplete="off">
            <div nz-row nzGutter="24">
                <nz-form-item nz-col nzSpan="4">
                    <nz-form-control>
                        <input type="search" nz-input placeholder="名称" formControlName="name" />
                    </nz-form-control>
                </nz-form-item>
                <nz-form-item nz-col nzSpan="4">
                    <nz-form-control>
                        <nz-select formControlName="appStatus" nzAllowClear nzPlaceHolder="所有状态">
                            <nz-option [nzValue]="1" nzLabel="运行中"></nz-option>
                            <nz-option [nzValue]="0" nzLabel="停止"></nz-option>
                        </nz-select>
                    </nz-form-control>
                </nz-form-item>
                <nz-form-item nz-col nzSpan="4">
                    <nz-form-control>
                        <input type="search" nz-input placeholder="路径" formControlName="appPath" />
                    </nz-form-control>
                </nz-form-item>
                <nz-form-item nz-col nzSpan="4">
                    <nz-form-control>
                        <input type="search" nz-input placeholder="主模组" formControlName="mainModuleName" />
                    </nz-form-control>
                </nz-form-item>
                <nz-form-item nz-col nzSpan="6">
                    <nz-form-control>
                        <input type="search" nz-input placeholder="参数" formControlName="parameters" />
                    </nz-form-control>
                </nz-form-item>
                <nz-form-item nz-col nzSpan="2">
                    <nz-form-control>
                        <button nz-button nzType="primary" (click)="search()">查询</button>
                    </nz-form-control>
                </nz-form-item>
            </div>
        </form>
    </nz-page-header-content>
</nz-page-header>
<nz-table #filterTable [nzData]="listOfDisplayData" nzFrontPagination="false" [nzLoading]="dataLoading">
    <thead (nzSortChange)="sort($event)" nzSingleSort>
        <tr>
            <th nzShowSort nzSortKey="Name">名称</th>
            <th nzShowSort nzSortKey="AppStatusText">状态</th>
            <th nzShowSort nzSortKey="AppPath">路径</th>
            <th nzShowSort nzSortKey="MainModuleName">主模组</th>
            <th nzShowSort nzSortKey="Parameters">参数</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let data of listOfDisplayData">
            <td>{{ data.Name }}</td>
            <td>{{ data.AppStatusText }}</td>
            <td>{{ data.AppPath }}</td>
            <td>{{ data.MainModuleName }}</td>
            <td>{{ data.Parameters }}</td>
            <td>
                <nz-button-group *ngIf="data.AppStatus === 0">
                    <button nz-button (click)="openDrawer(data.ID)">配置</button>
                    <button nz-button nzType="primary" (click)="StartApp(data.ID)">启动</button>
                    <button nz-button nzType="danger" (click)="showDeleteConfirm(data.ID)">删除</button>
                </nz-button-group>
                <nz-button-group *ngIf="data.AppStatus === 1">
                    <button nz-button (click)="getConsoleList(data.ID)">控制台</button>
                    <button nz-button nzType="danger" (click)="StopApp(data.ID)">停止</button>
                </nz-button-group>
            </td>
        </tr>
    </tbody>
</nz-table>
<nz-drawer [nzWidth]="720" [nzVisible]="drawerVisible" [nzTitle]="isAdd?'添加应用':'修改应用'" (nzOnClose)="closeDrawer()">
    <app-app-edit #appEditComponent (saveEnd)="saveEnd($event)"></app-app-edit>
</nz-drawer>
<nz-modal [(nzVisible)]="modalVisible" nzTitle="控制台消息" nzCancelText="关闭" nzWidth="90%" [nzFooter]="modalFooter" (nzOnCancel)="closeModal()">
    <p class="console-message" *ngFor="let message of consoleMessages">{{message}}</p>
    <ng-template #modalFooter>
        <button nz-button (click)="closeModal()">关闭</button>
    </ng-template>
</nz-modal>